package com.gitee.sop.websiteserver.controller;

import com.gitee.sop.mongodb.MongoConstants;
import com.gitee.sop.mongodb.MongoDTO;
import com.gitee.sop.mongodb.MongoLike;
import com.gitee.sop.websiteserver.bean.Result;
import com.gitee.sop.websiteserver.controller.param.CustomUserPageParam;
import com.gitee.sop.websiteserver.service.CustomUserService;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;
import javax.validation.Valid;
import java.util.HashSet;
import java.util.Set;

/**
 * 资源信息接口
 *
 * @author admin
 */
@RestController
@RequestMapping("portal/user")
public class UserController {
    @Resource
    private CustomUserService customUserService;

    @GetMapping("/page")
    public Result page(@Valid CustomUserPageParam pageParam) {
        MongoDTO mongoDTO = new MongoDTO();
        Set<MongoLike> queryParams = new HashSet<>();
        MongoLike mongoLike = new MongoLike();
        mongoLike.setKey("username");
        mongoLike.setValue(pageParam.getUsername());
        mongoLike.setMatch(MongoConstants.query7);
        queryParams.add(mongoLike);
        mongoDTO.setQueryParams(queryParams);

        customUserService.queryPageByParam(mongoDTO);
        return Result.ok();
    }
}
